package com.socket.socketTest;

import java.io.*;
import java.net.Socket;

/**
 * LoginClient--bdqnPractice
 *
 * @author: Jovi
 * @createTime: 2017-09-06 16:14
 **/
public class LoginClient {

    public static void main(String[] args) {
        try {
            Socket socket = new Socket("localhost", 8800);
            OutputStream os = socket.getOutputStream();
            PrintWriter pw = new PrintWriter(os);

            InputStream is = socket.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));


            String request = "hello server";
            pw.write(request);
            pw.flush();

            socket.shutdownOutput();

            String repay;
            while ((repay = br.readLine()) != null) {
                System.out.println("我是客户端，服务器响应为："+repay);
            }

            br.close();
            is.close();
            pw.close();
            os.close();
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
